<?php

define("VL_LEGAL", true);

require_once($_SERVER["DOCUMENT_ROOT"]."/sys/includes/const.inc.php");
require_once(VL_DIR_CLASSES."vlAPI.class.php");

/**
 * Главный объект системы
 * @var vlAPI
 */
$API=&vlAPI::getInstance();

$API->loadConfig(VL_DIR_INCLUDES."config.inc.php");

$request=array();
$tmp=explode("/", $_GET["alias"]);
if($tmp[0]!="") $request["module"]=$tmp[0];
else $request["module"]="homepage";
for($i=1; $i<count($tmp); $i++)
	if($tmp[$i]!="") $request["params"][]=$tmp[$i];

$file=VL_DIR_MANAGER_MODULES.$request["module"]."/index.php";
$module=array();
if(file_exists($file)) {
	ob_start();
	$module=include($file);
	ob_end_clean();
}

if($API->user->isLoggedIn()) {
	?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?=$module["title"]?> :: Панель управления vlCMS</title>
<script type="text/javascript" src="<?=VL_WEB_JS?>jquery.js"></script>
<script type="text/javascript" src="<?=VL_WEB_JS?>jquery_ui.js"></script>
<script type="text/javascript" src="<?=VL_WEB_JS?>manager.js.php"></script>
<link rel="stylesheet" href="<?=VL_WEB_MANAGER_THEMES?>smoothness/jquery_ui.css" />
<link rel="stylesheet" href="<?=VL_WEB_MANAGER_THEMES?>smoothness/manager.css" />
</head>
<body>
	<table class="bodytb" cellspacing="0" cellpadding="0">
	<tr>
		<td class="tbtoplogo">
			<img src="<?=VL_WEB_MANAGER_THEMES?>smoothness/images/logo.png" alt="vlCMS" />
		</td>
		<td class="tbtopmenu1">
			<div class="mgr_buttonset">
				<a href="/manager/shota" id="test">Button 1</a>
			</div>
		</td>
		<td class="tbtopmenu2">
			<div class="mgr_buttonset">
				<a href="<?=VL_WEB_MANAGER_MODULES?>profile/" id="btn_profile">Профиль</a>
				<a href="<?=VL_WEB_MANAGER_MODULES?>messages/" id="btn_messages">Сообщения</a>
				<form action="" method="POST">
					<input type="hidden" name="vllogout" value="1" />
					<input type="submit" value="Выход" id="btn_exit" />
				</form>
			</div>
		</td>
	</tr>
	</table>
	<table class="bodytb" cellspacing="0" cellpadding="0">
	<tr>
		<td class="tbmenu">
			<div class="ui-corner-all menu">
				<p class="menu_title">Структура сайта</p>
				<div id="panel_site">
					<div class="mgr_buttonset">
						<button id="btn_sitetree_create">Создать</button>
						<button id="btn_sitetree_refresh">Обновить</button>
					</div>
					<a href="javascript:$.vlcms.manager.loadModule('sitetree/formtree')"><strong>Сайт</strong></a>
					<div id="sitetree">Загрузка дерева сайта...</div>
				</div>
			</div>
			<div class="ui-corner-all menu">
				<p class="menu_title">Lorem Ipsum</p>
				<div id="panel2">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>
			</div>
			<div class="ui-corner-all menu">
				<p class="menu_title">3</p>
				<div id="panel3">egergrth</div>
			</div>
		</td>
		<td class="tbcontent">
			<div id="title"><?=$module["title"]?></div>
			<table class="bodytb" cellspacing="0" cellpadding="0">
			<tr>
				<td class="toolbar1">
					<div class="mgr_buttonset" id="tlbleft"><?=$module["toolbarLeft"]?></div>
				</td>
				<td class="toolbar2">
					<div class="mgr_buttonset" id="tlbright"><?=$module["toolbarRight"]?></div>
				</td>			
			</tr>
			</table>
			<div id="content"><?=$module["content"]?></div>
		</td>
	</tr>
	</table>
	<div id="mgr_dialog" title=""></div>
</body>
</html>
	<?
} else $API->loginPage();